package edu.unicen;

import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderConfiguration;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;

import edu.unicen.beans.Actor;
import edu.unicen.beans.Task;

public class MainApp {
	

	public MainApp(){
		KnowledgeBuilderConfiguration kbuilderconfiguration = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();

		final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
		kbuilder.add( ResourceFactory.newClassPathResource( "task.drl",
				Task.class ),
				ResourceType.DRL);

		final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
		kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

		final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
	

		Task task = new Task();
		Actor actor = new Actor();
		task.setProperty("name", "nombre1");
		task.setProperty("skill", "dev1");
		actor.setProperty("skill", "dev");
		actor.addTask(task);
	    ksession.insert(task);
	    ksession.insert(actor);
	    
	    ksession.fireAllRules();
		
	    }


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		MainApp mainApp = new MainApp();

	}

}
